﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace AGrandVenture
{
    public class InventoryItem
    {
        #region Enums

        public enum ItemType
        {
            Weapon, Shield, Armor, Consumable, Resource, Quest
        };

        public enum ItemRarity
        {
            Trash, Common, Uncommon, Rare, Legendary, Mythic
        };

        public enum EquipmentSlot
        {
            None, Primary, Offhand,
            Head, Chest, Back, Shoulders,
            Arms, Hands, Waist,
            Legs, Feet, Ear, Trinket, 
            Finger, Neck
        };
        #endregion

        #region Declaration
        private string itemName = "";
        private int itemLevel = 0;
        private UInt64 seedValue;
        private Sprite spriteBase;
        private EquipmentSlot equipSlot = EquipmentSlot.None;
        private bool isEquipped = false;
        private Color tintColor = Color.White;
        private ItemType iType;
        private ItemRarity rarity = ItemRarity.Trash;
        private int iWeight = 0;
        private bool bCursed = false;//Cursed items cannot be removed without being uncursed
        private double baseValue,
                    bonusHP,
                    bonusEnergy,
                    bonusStrength,
                    bonusAgility,
                    bonusConstitution,
                    bonusCharisma,
                    bonusIntelligence,
                    bonusLuck,
                    bonusMinDmg,
                    bonusMaxDmg,
                    bonusRange,
                    bonusAttackSpeed,
                    bonusArmorClass,
                    bonusPhysicalAttack,
                    bonusMagicalAttack,
                    bonusCriticalStrike,
                    bonusMentalResistance,
                    bonusArcaneResistance,
                    bonusPoisonResistance,
                    bonusFireResistance,
                    bonusColdResistence = 0;

        #endregion

        #region Properties

        public Sprite Base
        {
            get { return spriteBase; }
            set { spriteBase = value; }
        }
        public ItemType Type
        {
            get { return iType; }
            set { iType = value; }
        }
        public string Name
        {
            get { return itemName; }
            set { itemName = value; }
        }
        public int Level
        {
            get { return itemLevel; }
            set { itemLevel = value; }
        }
        public EquipmentSlot EquipSlot
        {
            get { return equipSlot; }
            set { equipSlot = value; }
        }
        public ItemRarity Rarity
        {
            get { return rarity; }
            set { rarity = value; }
        }
        public double BaseValue
        {
            get { return baseValue; }
            set { baseValue = value; }
        }
        public int Weight
        {
            get { return iWeight; }
            set { iWeight = value; }
        }
        public bool IsEquipped
        {
            get { return isEquipped; }
            set { isEquipped = value; }
        }
        public bool IsCursed
        {
            get { return bCursed; }
            set { bCursed = value; }
        }
        public double BonusHP
        {
            get { return bonusHP; }
            set { bonusHP = value; }
        }
        public double BonusEnergy
        {
            get { return bonusEnergy; }
            set { bonusEnergy = value; }
        }
        public double BonusStrength
        {
            get { return bonusStrength; }
            set { bonusStrength = value; }
        }
        public double BonusAgility
        {
            get { return bonusAgility; }
            set { bonusAgility = value; }
        }
        public double BonusConstitution
        {
            get { return bonusConstitution; }
            set { bonusConstitution = value; }
        }
        public double BonusCharisma
        {
            get { return bonusCharisma; }
            set { bonusCharisma = value; }
        }
        public double BonusIntelligence
        {
            get { return bonusIntelligence; }
            set { bonusIntelligence = value; }
        }
        public double BonusLuck
        {
            get { return bonusLuck; }
            set { bonusLuck = value; }
        }
        public double BonusMinDmg
        {
            get { return bonusMinDmg; }
            set { bonusMinDmg = value; }
        }
        public double BonusMaxDmg
        {
            get { return bonusMaxDmg; }
            set { bonusMaxDmg = value; }
        }
        public double BonusRange
        {
            get { return bonusRange; }
            set { bonusRange = value; }
        }
        public double BonusAttackSpeed
        {
            get { return bonusAttackSpeed; }
            set { bonusAttackSpeed = value; }
        }
        public double BonusAC
        {
            get { return bonusArmorClass; }
            set { bonusArmorClass = value; }
        }
        public double BonusPhysicalAttack
        {
            get { return bonusPhysicalAttack; }
            set { bonusPhysicalAttack = value; }
        }
        public double BonusMagicalAttack
        {
            get { return bonusMagicalAttack; }
            set { bonusMagicalAttack = value; }
        }
        public double BonusCriticalStrike
        {
            get { return bonusCriticalStrike; }
            set { bonusCriticalStrike = value; }
        }
        public double BonusMentalResistance
        {
            get { return bonusMentalResistance; }
            set { bonusMentalResistance = value; }
        }
        public double BonusArcaneResistance
        {
            get { return bonusArcaneResistance; }
            set { bonusArcaneResistance = value; }
        }
        public double BonusPoisonResistance
        {
            get { return bonusPoisonResistance; }
            set { bonusPoisonResistance = value; }
        }
        public double BonusFireResistance
        {
            get { return bonusFireResistance; }
            set { bonusFireResistance = value; }
        }
        public double BonusColdResistance
        {
            get { return bonusColdResistence; }
            set { bonusColdResistence = value; }
        }

        public UInt64 Seed
        {
            get { return seedValue; }
            set { seedValue = value; }
        }
        #endregion
        public void clearBonusStats()
        {
            BonusHP = 0;
            BonusEnergy = 0;
            BonusStrength = 0;
            BonusAgility = 0;
            BonusConstitution = 0;
            BonusCharisma = 0;
            BonusIntelligence = 0;
            BonusLuck = 0;
            BonusMinDmg = 0;
            BonusMaxDmg = 0;
            BonusRange = 0;
            BonusAttackSpeed = 0;
            BonusAC = 0;
            BonusPhysicalAttack = 0;
            BonusMagicalAttack = 0;
            BonusCriticalStrike = 0;
            BonusMentalResistance = 0;
            BonusArcaneResistance = 0;
            BonusPoisonResistance = 0;
            BonusFireResistance = 0;
            BonusColdResistance = 0;
        }
        #region Gray Prefix/Suffix Bonuses
        public void setBonusesByGrayPrefix(string prefix, int level)
        {
            double lvlMod = 1 + (double)(level / 99);
            switch (prefix)
            {
                case "Quivering":
                    BonusAgility += 1 * lvlMod;
                    break;
                case "Malevolent":
                    BonusIntelligence += 1 * lvlMod;
                    BonusCriticalStrike += 1 * lvlMod;
                    Base.TintColor = Color.Red;
                    break;
                case "Violent":
                    BonusMinDmg -= 1 * lvlMod;
                    BonusMaxDmg += 1 * lvlMod;
                    Base.TintColor = Color.Purple;
                    break;
                case "Nauseating":
                    BonusMentalResistance -= 1 * lvlMod;
                    BonusConstitution -= 1 * lvlMod;
                    Base.TintColor = Color.Lime;
                    break;
                case "Vibrating":
                    BonusCriticalStrike += 1 * lvlMod;
                    BonusAgility -= 1 * lvlMod;
                    break;
                case "Curious":
                    BonusIntelligence += 1 * lvlMod;
                    BonusMentalResistance -= 1 * lvlMod;
                    Base.TintColor = Color.Pink;
                    break;
                case "Bi-Curious":
                    BonusCharisma += 2 * lvlMod;
                    BonusPoisonResistance -= 1 * lvlMod;
                    Base.TintColor = Color.Orange;
                    break;
                case "Gay":
                    BonusCharisma += 1 * lvlMod;
                    BonusPoisonResistance -= 2 * lvlMod;
                    break;
                case "Straight":
                    BonusStrength += 1 * lvlMod;
                    BonusMaxDmg += 1 * lvlMod;
                    BonusAC += 1 * lvlMod;
                    break;
                case "Cloudy":
                    BonusLuck += 1 * lvlMod;
                    BonusAC += 1 * lvlMod;
                    Base.TintColor = Color.LightBlue;
                    break;
                case "Holey":
                    BonusMagicalAttack += 1 * lvlMod;
                    BonusMentalResistance += 1 * lvlMod;
                    Base.TintColor = Color.Gray;
                    break;
                case "Floppy":
                    BonusStrength -= 1 * lvlMod;
                    BonusCharisma += 1 * lvlMod;
                    break;
                case "Goofy":
                    BonusCharisma += 2 * lvlMod;
                    BonusAC += 1 * lvlMod;
                    break;
                case "Ragged":
                    BonusCriticalStrike += 2 * lvlMod;
                    BonusRange -= 0.5 * lvlMod;
                    Base.TintColor = Color.MediumVioletRed;
                    break;
                case "Fuzzy":
                    BonusMentalResistance -= 1 * lvlMod;
                    BonusAC += 1 * lvlMod;
                    BonusAttackSpeed += 0.5 * lvlMod;
                    break;
                case "Diseased":
                    BonusConstitution -= 1 * lvlMod;
                    BonusCharisma -= 1 * lvlMod;
                    BonusLuck -= 1 * lvlMod;
                    BonusMinDmg += 1 * lvlMod;
                    Base.TintColor = Color.Brown;
                    break;
                case "Leperous":
                    BonusConstitution -= 2 * lvlMod;
                    BonusCharisma -= 2 * lvlMod;
                    BonusCriticalStrike += 2 * lvlMod;
                    BonusRange += 0.5 * lvlMod;
                    BonusLuck -= 2 * lvlMod;
                    Base.TintColor = Color.BlanchedAlmond;
                    break;
                case "Catchy":
                    BonusCharisma += 1 * lvlMod;
                    BonusConstitution += 1 * lvlMod;
                    BonusAC -= 1 * lvlMod;
                    break;
                case "Conniving":
                    BonusIntelligence += 2 * lvlMod;
                    BonusCharisma -= 1 * lvlMod;
                    BonusAgility += 1 * lvlMod;
                    break;
                case "Political":
                    BonusCharisma -= 3 * lvlMod;
                    BonusAC += 3 * lvlMod;
                    BonusLuck += 2 * lvlMod;
                    break;
                case "Jabbering":
                    BonusMentalResistance += 2 * lvlMod;
                    BonusHP += 5 * lvlMod;
                    BonusIntelligence -= 1 * lvlMod;
                    break;
                default:
                    break;
            }
        }
        public void setBonusesByGraySuffix(string suffix, int level)
        {
            double lvlMod = 1 + (double)(level / 99);
            switch (suffix)
            {
                case "Helplessness":
                    BonusAC -= 2 * lvlMod;
                    BonusHP -= 3 * lvlMod;
                    break;
                case "Muckiness":
                    BonusAC += 2 * lvlMod;
                    BonusFireResistance += 1 * lvlMod;
                    break;
                case "Cowardice":
                    BonusAC += 5 * lvlMod;
                    BonusCharisma -= 2 * lvlMod;
                    BonusMentalResistance -= 2 * lvlMod;
                    break;
                case "Slime":
                    BonusCharisma -= 2 * lvlMod;
                    BonusAttackSpeed -= 0.5 * lvlMod;
                    BonusMinDmg += 1 * lvlMod;
                    break;
                case "Giddyness":
                    BonusCharisma += 1 * lvlMod;
                    BonusLuck += 1 * lvlMod;
                    break;
                case "Disaster":
                    BonusLuck -= 3 * lvlMod;
                    BonusStrength += 1 * lvlMod;
                    BonusMinDmg += 1 * lvlMod;
                    BonusCriticalStrike += 1 * lvlMod;
                    break;
                case "Chaos":
                    BonusLuck += 2 * lvlMod;
                    BonusMinDmg -= 1 * lvlMod;
                    BonusMaxDmg += 2 * lvlMod;
                    BonusAttackSpeed += 0.75 * lvlMod;
                    break;
                case "Stank":
                    BonusCharisma -= 3 * lvlMod;
                    BonusAC += 5 * lvlMod;
                    break;
                case "Glitter":
                    BonusLuck += 2 * lvlMod;
                    BonusMagicalAttack += 2 * lvlMod;
                    break;
                case "Gluttony":
                    BonusStrength += 3 * lvlMod;
                    BonusCriticalStrike -= 0.5 * lvlMod;
                    BonusIntelligence -= 1 * lvlMod;
                    break;
                case "Laziness":
                    BonusHP += 10 * lvlMod;
                    BonusLuck += 1 * lvlMod;
                    BonusAgility -= 2 * lvlMod;
                    break;
                case "Lustfulness":
                    BonusCharisma += 2 * lvlMod;
                    BonusLuck += 2 * lvlMod;
                    BonusMaxDmg -= 1 * lvlMod;
                    break;
                case "Envy":
                    BonusCharisma += 2 * lvlMod;
                    break;
                case "Pride":
                    BonusAC -= 3 * lvlMod;
                    BonusCharisma -= 1 * lvlMod;
                    BonusConstitution += 2 * lvlMod;
                    BonusFireResistance += 2 * lvlMod;
                    BonusMentalResistance += 2 * lvlMod;
                    break;
                case "Bad Intentions":
                    BonusLuck -= 1 * lvlMod;
                    BonusMaxDmg += 2 * lvlMod;
                    BonusMagicalAttack += 1 * lvlMod;
                    break;
                case "No Respect":
                    BonusRange += 0.25 * lvlMod;
                    BonusCriticalStrike += 0.25 * lvlMod;
                    BonusCharisma -= 1 * lvlMod;
                    break;
                case "Discontent":
                    BonusStrength += 1 * lvlMod;
                    BonusColdResistance += 1 * lvlMod;
                    break;
                case "Moistness":
                    BonusColdResistance -= 3 * lvlMod;
                    BonusFireResistance += 3 * lvlMod;
                    BonusConstitution += 1 * lvlMod;
                    break;
                case "Loneliness":
                    BonusCharisma -= 2 * lvlMod;
                    BonusIntelligence -= 1 * lvlMod;
                    BonusMinDmg += 1 * lvlMod;
                    BonusMentalResistance -= 1 * lvlMod;
                    break;
                case "Wrath":
                    BonusStrength += 2 * lvlMod;
                    BonusAgility += 2 * lvlMod;
                    BonusAttackSpeed += 1 * lvlMod;
                    BonusCriticalStrike += 0.5 * lvlMod;
                    BonusHP -= 10 * lvlMod;
                    break;
                case "Wobbliness":

                    BonusConstitution -= 1 * lvlMod;
                    BonusLuck += 2 * lvlMod;
                    BonusIntelligence += 1 * lvlMod;
                    break;
            }
        }
        #endregion

        #region HelperMethods

        #endregion
    }
}
